package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.RepairsMapper;
import com.pojo.Repairs;
import com.service.RepairsService;
import com.vo.RepairsVo;
import com.vo.repairsStateVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("repairsService")
public class RepairsServiceImpl implements RepairsService {
    @Resource
    private RepairsMapper repairsMapper;
    @Override
    public List<Repairs> selectReqairsByVo(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList = repairsMapper.selectRepairsByVo(repairsVo);
        return repairsList;
    }

    @Override
    public int addReqairs(Repairs repairs) {
        repairs.setRepstateid(1);
        int i = repairsMapper.insertSelective(repairs);
        return i;
    }



    @Override
    public int updateState(repairsStateVo repairsStateVo) {
        int updatesatae = repairsMapper.updatesatae(repairsStateVo);
        return updatesatae;
    }

    @Override
    public PageInfo<Repairs> selectRecording(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList = repairsMapper.selectRecording(repairsVo);
        PageInfo<Repairs> pageInfo=new PageInfo<>(repairsList);
        return pageInfo;
    }

    @Override
    public PageInfo<Repairs> selectAllRepairs(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList = repairsMapper.selectAllRepairs(repairsVo);
        PageInfo<Repairs> pageInfo=new PageInfo<>(repairsList);
        return pageInfo;
    }

    @Override
    public PageInfo<Repairs> selectAllRepairsjob(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList=repairsMapper.selectAllRecordingJob(repairsVo);
        PageInfo<Repairs> pageInfo=new PageInfo<>(repairsList);
        return pageInfo;
    }

    @Override
    public int updateRepairs(Repairs repairs) {
        int i = repairsMapper.updateByPrimaryKeySelective(repairs);
        return i;
    }

    @Override
    public int updateEmployee(repairsStateVo repairsStateVo) {
        int i = repairsMapper.updateEmployee(repairsStateVo);
        return i;
    }

    @Override
    public PageInfo<Repairs> selectAllRepairing(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList = repairsMapper.selectAllRepairing(repairsVo);
        PageInfo<Repairs> pageInfo=new PageInfo<>(repairsList);
        return pageInfo;
    }

    @Override
    public Repairs selectReparisDetails(Integer id) {
        Repairs repairs = repairsMapper.selectRepairsDetails(id);
        return repairs;
    }

    @Override
    public List<Repairs> selecttoptenrepairs() {
        List<Repairs> selecttoptenrepairs = repairsMapper.selecttoptenrepairs();
        return selecttoptenrepairs;
    }
    @Override
    public PageInfo<Repairs> selectReparisByElefinishi(RepairsVo repairsVo) {
        PageHelper.startPage(repairsVo.getPage(),repairsVo.getLimit());
        List<Repairs> repairsList = repairsMapper.selectReparisByElefinish(repairsVo);
        PageInfo<Repairs> repairsPageInfo=new PageInfo<>(repairsList);
        return repairsPageInfo;
    }


}
